<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Commodity edit</title>
<script type="text/javascript" src="Javascript/DateCheck.js"></script>
<LINK REL="stylesheet" HREF="CSS/Main.css" TYPE="text/css">
<LINK REL="stylesheet" HREF="CSS/Button.css" TYPE="text/css">
</head>
<body>

<div id="top">
		<h1>Master Data Management</h1>
		<br>
		<a id="log" href="logout">Logout</a><br>
    		<%@ include file="redirection.jsp" %>
	</div>

	<h2>Commodity Edit</h2>

	<div id="left">
		<div class="box">

			<%
                                 String[] mark = (String[]) request.getAttribute("commodity");
                                 if (mark == null) {
                           %>
		<form name='header' action='CommodityEdit' method="get">
				<script type="text/javascript">
                                       document.forms['header'].submit();
                                 </script>
			</form>
			<%
                                 }
                           %>

			<form action="CommodityEdit" method="get">
				<table>
					<tr>
						<td><select name="selected">
								<%if(mark!=null){
                                
									for(String s:mark){%>
								<option value="<%=s%>"><%=s%></option>
								<%}}%>
						</select></td>
						<td><input type="submit" class="button" name="show"
							value="Show Details"></td>
					</tr>
				</table>
			</form>

		</div>
		<div class="visbox">
			<table>
				<tr>
					<td>
					</td>
					<td>
						<%if(session.getAttribute("role").equals("admin")){%>
				<form action="Home.jsp">
					<input type="submit" class="button"name="Home" value="Home">
				</form>		
				<form action = "ControlPanel.jsp">
	<input type="submit" name="Back" class="button" value="Back" >
</form>
			<%}else{%>
			<form action = "ControlPanelUser.jsp">
	<input type="submit" name="Back" class="button" value="Back" >
</form>
				<form action="HomeUser.jsp">
					<input type="submit" class="button"name="Home" value="Home">
				</form>	
			<% }%>	
					</td>
				</tr>
			</table>
		</div>
	</div>





	 <div id="right">
		<form action="CommodityEdit" method="post" onsubmit="return v()">
			<%	String[] details = (String[]) request.getAttribute("commodityDetails");
				if (details != null) {  %>
			<table border="1" width="600">
				<tr>
					<td>commodity Name</td>
					<td>commodity class</td>
				 	<td>Start Date</td>
					<td>End date</td>
					<td>Flag</td>  
				</tr>
				<tr>
					<td><input type="hidden" name="commodityName" value="<%=details[0]%>"><%=details[0]%></td>
					<td><input type="text" name="commodityClass" value="<%=details[1]%>" required></td>
				 	<td><input type="text" id="startDate" name="startDate"	placeholder="<%=details[2]%>" value="<%=details[2]%>"></td>
					<td><input type="text" id="endDate" name="endDate"	placeholder="<%=details[3]%>" value="<%=details[3]%>"></td> 
					<td><input type="hidden" name="oldFlag" value="<%=details[6]%>">
						<select name="SelectFlag">	
							<% if(details[6].equals("N")){ %>
								<option value="N" selected>No</option>
								<option value="Y">Yes</option>
							<% 	}
								else{%>
									<option value="N">No</option>
									<option value="Y" selected>Yes</option>
								<%}%> 
						</select>
					</td>
				</tr>
			</table>
			<br> <input type="submit" class="button" name="edit"
				value="Edit"> <br>
			<%} %>
			
		</form>
		<article id="warning"></article><br>
		<%=(request.getAttribute("status") == null) ? "" : request.getAttribute("status")%>
	</div>
	<br>
</body>
</html>